﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Main.Master" AutoEventWireup="true"
    CodeBehind="Overview.aspx.cs" Inherits="APMS.WebSite.Views.Project.Overview" %>

<%@ Import Namespace="APMS.WebSite.Common" %>    
<%@ Import Namespace="APMS.WebSite.Models.DataStore" %>
<%@ Import Namespace="APMS.WebSite.Models.ViewData" %>
<%@ Import Namespace="APMS.WebSite.Models.ViewData.UserControls" %>
    

<asp:Content ID="ScriptContent" ContentPlaceHolderID="head" runat="server">
   <%-- <% 
        Project currentProject = ViewData[ProjectController.CURRENT_PROJECT] as Project;
        ViewData["ProjectName"] = currentProject.ProjectName;
    %>--%>

	<!-- TODO: Move to APMSSite.js -->
	<script type="text/javascript" language="javascript">
        $(document).ready(function(){

        });
	</script>
</asp:Content>	
<asp:Content ID="PageTitleContent" ContentPlaceHolderID="PageTitleHolder" runat="server">
    <h2 class="nodesc"><%= Html.Encode(ViewData.Model.CurrentProject.ProjectName)%></h2>
    <h3>Project Overview &amp; Activity</h3>
</asp:Content>
<asp:Content ID="NavigationMenuContent" ContentPlaceHolderID="NavigationMenuHolder" runat="server">
	<% if (ViewData[BaseController.MAIN_NAV] is MainNavViewData) {%>
        <%=Html.RenderUserControl("~/Views/Shared/UserControls/MainNav.ascx", ViewData[BaseController.MAIN_NAV])%>
     <% } %>
</asp:Content>
<asp:Content ID="CommandLinkContent" ContentPlaceHolderID="CommandLinkHolder" runat="server">
    <%--TODO: Use HTML Action Links here--%>
    <ul id="commands" class="commandLink">
        <li><%=Html.ActionLink<MessageController>(x => x.Create(ViewData.Model.CurrentProject.ProjectID), "New Message", new { @class = "newMsg" })%></li>
        <li><%=Html.ActionLink<TodoController>(x => x.Create(ViewData.Model.CurrentProject.ProjectID), "New To-Do List", new { @class = "newTodo" })%></li>
        <li><%=Html.ActionLink<WriteboardController>(x => x.Create(ViewData.Model.CurrentProject.ProjectID), "New Writeboard Topic", new { @class = "newWB" })%></li>
    </ul>
</asp:Content>
<asp:Content ID="SidebarContent" ContentPlaceHolderID="SidebarHolder" runat="server">
    <%--TODO: Create Widget Custom Server Control--%>
    <div class="widget">
	    <h3 class="widgetTitle"><a href="#"><img class="rssfeed" src="../../Content/Default/images/feed.png" align="absmiddle" alt="RSS Feed" /></a>Project's RSS feed</h3>
		<p class="widgetContent">
		    <a href="#">Subscribe to your project RSS feed</a> and be notified when someone posts a message, comment or file, or adds or completes a to-do item or milestone in this project. <a target="_blank" href="http://www.feedburner.com/fb/a/aboutrss">What's RSS?</a>
		</p>
    </div>
    <%--TODO: Create Widget Custom Server Control--%>
	<div class="widget">
		<h3 class="widgetTitle">People on this project</h3>
		<ul class="widgetContent">
		    <li>User1</li>
			<li>User2</li>
			<li>User3</li>
			<li>User4</li>
		</ul>
	</div>
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="ContentHolder" runat="server">
    
    <%--TODO: Create MileStone Custom Server Control or UserControl--%>
    <%=Html.RenderUserControl("~/Views/Shared/UserControls/ProjectCalendar.ascx", ViewData[ProjectController.PROJECT_CALENDAR])%>
    
    
    <%
        List<EventItem> allEvents = ViewData.Model.EventItems;
        StringBuilder builder = new StringBuilder();

        builder.AppendLine("<table class=\"overview\">");
        builder.AppendLine("<tbody>");

        //// Back 1 week
        //DateTime markDate = DateTime.Today;
        //DateTime currentDate;
        //for (int i = 0; i < 7; i++)
        //{
        //    currentDate = markDate.Subtract(
        //}

        builder.AppendFormat("<tr class=\"date\"><td colspan=\"4\"><h3 class=\"date widgetTitle\"><span>{0}</span></h3></td></tr>", 
            "Events in last 7 days");
        
        foreach (EventItem item in allEvents)
        {
            builder.Append("<tr id=\"event_idgen002\" class=\"event\"><td class=\"what\">");
            
            if(item.Type == EventType.ToDo)
                builder.Append("<span class=\"todo\">To-Do</span>"); 
            else if(item.Type == EventType.Message)
                builder.Append("<span class=\"msg\">Message</span>");
            else if (item.Type == EventType.Writeboard)
                builder.Append("<span class=\"wbs\">Writeboard</span>");

            builder.Append("</td>");
            builder.AppendFormat("<td class=\"item\"><span>{0}</span><span class=\"list\">(<a href=\"#\">{1}</a>)</span>",
                item.Summary,
                item.Location);
            builder.Append("</td>");
            builder.Append("<td class=\"action\">Assigned to</td>");
            builder.AppendFormat("<td class=\"name\">{0}</td>", item.AssignedTo);
            builder.Append("</tr>");
        }

        builder.AppendLine("</tbody>");
        builder.AppendLine("</table>");

        Response.Flush();
        Response.Write(builder.ToString());
    %>
    
	<%--<table class="overview">
		<tbody>
			<!-- Events grouped by date-->
			<tr class="date">
				<td colspan="4">
					<h3 class="date widgetTitle"><span>Sunday, 20 July 2008</span></h3>
				</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen002" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen003" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen004" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen005" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
			<!-- Separated Group -->
			<!-- Events grouped by date-->
			<tr class="date">
				<td colspan="4">
					<h3 class="date widgetTitle"><span>Sunday, 20 July 2008</span></h3>
				</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen005" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen006" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen007" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
			<!-- Event- record -->
			<tr id="event_idgen008" class="event">
				<td class="what">
					<span class="todo">To-Do</span>
				</td>
				<td class="item">
					<span>AJAX using jQuery (or other 3rd party libs)</span>
					<span class="list">(<a href="#">Application Prototype - Web</a>)</span>
				</td>
				<td class="action">Assigned to</td>
				<td class="name">Anyone</td>
			</tr>
		</tbody>
	</table>--%>
	<!-- Sth else -->
</asp:Content>
